

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>User Guide &mdash; oBB Documentation</title>
  

  
  
    <link rel="shortcut icon" href="_static/favicon.ico"/>
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  

  

  
    <link rel="top" title="oBB Documentation" href="index.html"/>
        <link rel="prev" title="Installing oBB" href="install.html"/> 

  
  <script src="_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="index.html" class="icon icon-home"> oBB
          

          
          </a>

          
            
            
              <div class="version">
                0.8b
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
                <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="install.html">Installing oBB</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">User Guide</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#global-optimization">Global Optimization</a></li>
<li class="toctree-l2"><a class="reference internal" href="#how-to-use-obb">How to use oBB</a></li>
<li class="toctree-l2"><a class="reference internal" href="#optional-arguments">Optional Arguments</a></li>
<li class="toctree-l2"><a class="reference internal" href="#example-of-use">Example of Use</a></li>
<li class="toctree-l2"><a class="reference internal" href="#running-the-algorithm">Running the Algorithm</a></li>
<li class="toctree-l2"><a class="reference internal" href="#using-the-rbf-layer">Using the RBF Layer</a></li>
<li class="toctree-l2"><a class="reference internal" href="#rbf-layer-for-the-coconut-test-set">RBF Layer for the COCONUT Test Set</a></li>
<li class="toctree-l2"><a class="reference internal" href="#acknowledgements">Acknowledgements</a></li>
<li class="toctree-l2"><a class="reference internal" href="#references">References</a></li>
</ul>
</li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="index.html">oBB</a>
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          

 



<div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="index.html">Docs</a> &raquo;</li>
      
    <li>User Guide</li>
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="_sources/userguide.txt" rel="nofollow"> View page source</a>
          
        
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="user-guide">
<h1>User Guide<a class="headerlink" href="#user-guide" title="Permalink to this headline">¶</a></h1>
<p>This section describes the main interface to oBB and how to use it.</p>
<div class="section" id="global-optimization">
<h2>Global Optimization<a class="headerlink" href="#global-optimization" title="Permalink to this headline">¶</a></h2>
<p>oBB is designed to solve the global optimization problem</p>
<blockquote>
<div><div class="math">
\[\begin{split}&amp;\min_{x \in \mathbb{R}^n} f(x) \\
\text{s.t. } \; &amp;l \le x \le u \\
\text{and } \;  &amp;Ax \le b \\
                &amp;Ex = d\end{split}\]</div>
</div></blockquote>
<p>where the objective function <span class="math">\(f\)</span> has Lipschitz continuous gradient or Hessian. oBB does not need to know the Lipschitz constants explicitly, it merely requires the user to supply elementwise bounds on the Hessian or derivative tensor of the objective function (see <a class="reference internal" href="#how-to-use-obb">How to use oBB</a>). The linear inequality constraints <span class="math">\(Ax \le b\)</span> and equality constraints <span class="math">\(Ex = d\)</span> are optional but the bound constraints <span class="math">\(l \le x \le u\)</span> are required.</p>
<p>oBB uses local first or second order Taylor type approximations over balls within a parallel branch and bound framework. As with all branch and bound algorithms, the curse of dimensionality limits its use to low dimensional problems. The choice of whether to use first or second order approximations is down to the user  (see <a class="reference internal" href="#how-to-use-obb">How to use oBB</a>).</p>
<p>For an in-depth technical description of the algorithm see the tech-report <a class="reference internal" href="#cfg2013" id="id1">[CFG2013]</a> and the paper <a class="reference internal" href="#fgf2013" id="id2">[FGF2013]</a>, along with the Master's thesis <a class="reference internal" href="#g2015" id="id3">[G2015]</a> for the optional range reduction strategy.</p>
</div>
<div class="section" id="how-to-use-obb">
<h2>How to use oBB<a class="headerlink" href="#how-to-use-obb" title="Permalink to this headline">¶</a></h2>
<p>oBB requires the user to write a python script file that defines the functions and parameters necessary to solve the global optimization problem and then passes them to the main <strong>obb</strong> function (see <a class="reference internal" href="#example-of-use">Example of Use</a>). The necessary functions are determined by the choice of a first or second order approximation model. The following approximation models can be passed to oBB's <strong>obb</strong> function using the <strong>mod</strong> argument (see <a class="reference internal" href="#cfg2013" id="id4">[CFG2013]</a> for details):</p>
<ul class="simple">
<li>First order models: <strong>'q'</strong> - norm based,  <strong>'g'</strong>, <strong>'Hz'</strong>, <strong>'lbH'</strong>, <strong>'E0'</strong>, <strong>'Ediag'</strong> - minimum eigenvalue based</li>
<li>Second order models: <strong>'c'</strong> - norm based, <strong>'gc'</strong> - minimum eigenvalue based</li>
</ul>
<p>If using a first order model, the user is required to write the following functions:</p>
<ul class="simple">
<li><strong>f(x)</strong> - returns objective function <span class="math">\(f\)</span> at point <span class="math">\(x\)</span> (scalar)</li>
<li><strong>g(x)</strong> - returns gradient <span class="math">\(\nabla_x f\)</span> of objective function at <span class="math">\(x\)</span> (numpy 1D-array)</li>
</ul>
<p>along with the bounding function:</p>
<ul class="simple">
<li><strong>bndH(l,u)</strong> - returns two numpy 2D-arrays of elementwise lower and upper bounds on the Hessian <span class="math">\(\nabla_{xx} f\)</span> of the objective function over <span class="math">\([l,u]\)</span></li>
</ul>
<p>For a second order model the user is additionally required to write the function:</p>
<ul class="simple">
<li><strong>H(x)</strong> - returns Hessian <span class="math">\(\nabla_{xx} f\)</span> of objective function at <span class="math">\(x\)</span> (numpy 2D-array)</li>
</ul>
<p>and rather than <strong>bndH</strong> the bounding function:</p>
<ul class="simple">
<li><strong>bndT(l,u)</strong> - returns two numpy 3D-arrays of elementwise lower and upper bounds on the derivative tensor <span class="math">\(\nabla_{xxx} f\)</span> of the objective function over <span class="math">\([l,u]\)</span></li>
</ul>
<p>The type of parallel branch and bound algorithm to use should be passed to oBB's <strong>obb</strong> function using the <strong>alg</strong> argument and can be one of the following (see <a class="reference internal" href="#cfg2013" id="id5">[CFG2013]</a> for details):</p>
<ul class="simple">
<li><strong>'T1'</strong> - bounds in parallel</li>
<li><strong>'T2_individual'</strong>, <strong>'T2_synchronised'</strong> - tree in parallel</li>
<li><strong>'T2_synchronised_rr'</strong> - tree in parallel <em>with range reduction</em></li>
</ul>
<p>See <a class="reference internal" href="#example-of-use">Example of Use</a> for an in-depth worked example in python. Note that the range reduction strategy improves performance in many cases but may not always guarantee global optimality (see <a class="reference internal" href="#g2015" id="id6">[G2015]</a> for details).</p>
</div>
<div class="section" id="optional-arguments">
<h2>Optional Arguments<a class="headerlink" href="#optional-arguments" title="Permalink to this headline">¶</a></h2>
<p>oBB allows the user to specify several optional arguments that control the behaviour of the algorithm:</p>
<ul class="simple">
<li><strong>tol</strong> - objective function tolerance (e.g. <strong>1e-2</strong>, the default)</li>
<li><strong>toltype</strong> - tolerance type (<strong>'r'</strong> - relative [default], <strong>'a'</strong> - absolute)</li>
<li><strong>countf</strong> - count objective function evaluations (<strong>0</strong> - off, <strong>1</strong> - on [default])</li>
<li><strong>countsp</strong> - count subproblem evaluations (<strong>0</strong> - off, <strong>1</strong> - on [default])</li>
</ul>
<p>and if <a class="reference external" href="http://www.matplotlib.org/">matplotlib</a> is installed:</p>
<ul class="simple">
<li><strong>vis</strong> - visualisation of the algorithm in 2D (<strong>0</strong> - off [default], <strong>1</strong> - on)</li>
</ul>
<p>Note that the inequality constraint arguments <span class="math">\(A, b\)</span> and  equality constraint arguments <span class="math">\(E, d\)</span> are also optional as the optimization problem is only required to be bound constrained.</p>
<p>The user can also specify the QP solver that the algorithm calls to obtain feasible upper bounds (see <a class="reference internal" href="#cfg2013" id="id7">[CFG2013]</a> for details). At present the user can choose from <a class="reference external" href="http://cvxopt.org/">CVXOPT's qp solver</a> or the <a class="reference external" href="http://github.com/mpy/PyQuadProg/">QuadProg++ solver</a> using the optional argument:</p>
<ul class="simple">
<li><strong>qpsolver</strong> - QP solver to use (<strong>'cvxopt'</strong> - CVXOPT's qp [default], <strong>'quadprog'</strong> - QuadProg++)</li>
</ul>
<p>Note that the QuadProg++ solver is faster as it is written in C++ but has very limited error handling and may not work in all cases. The CVXOPT solver is slower as it is written in Python but considerably more stable.</p>
</div>
<div class="section" id="example-of-use">
<h2>Example of Use<a class="headerlink" href="#example-of-use" title="Permalink to this headline">¶</a></h2>
<p>Suppose we wish to solve the following global optimization problem:</p>
<blockquote>
<div><div class="math">
\[\begin{split}&amp;\min_{x \in \mathbb{R}^n} \sum_{i=1}^n \sin(x_i) \\
\text{s.t. } \; &amp;-1 \le x_i \le 1 \; \; \forall i=1,\dotsc,n \\
\text{and }  \; &amp;\sum_{i=1}^n -x_i \le 1\end{split}\]</div>
</div></blockquote>
<p>One can see that the gradient <span class="math">\(g\)</span>, Hessian <span class="math">\(H\)</span> and third order derivative tensor <span class="math">\(T\)</span> are given by</p>
<blockquote>
<div><div class="math">
\[\begin{split}&amp;g(x) = ( \cos(x_1), \dotsc, \cos(x_n))^T \\
&amp;H(x) = diag( -\sin(x_1), \dotsc, -\sin(x_n)) \\
&amp;T(x) = diagt( -\cos(x_1), \dotsc, -\cos(x_n))\end{split}\]</div>
</div></blockquote>
<p>where <span class="math">\(diagt\)</span> is the tensor diagonal function (i.e. <span class="math">\(diagt(v)\)</span> places the vector <span class="math">\(v\)</span> on the diagonal of the tensor).</p>
<p>It is straightforward to obtain elementwise bounds on the Hessian matrix <span class="math">\(H\)</span> and third order derivative tensor <span class="math">\(T\)</span> as both <span class="math">\(sin\)</span> and <span class="math">\(cos\)</span> can be bounded below and above by -1 and 1 respectively.</p>
<p>We can code this up in a python script file, let's call it sines.py as follows:</p>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># Example code for oBB</span>
<span class="kn">from</span> <span class="nn">obb</span> <span class="kn">import</span> <span class="n">obb</span>
<span class="kn">from</span> <span class="nn">numpy</span> <span class="kn">import</span> <span class="n">sin</span><span class="p">,</span> <span class="n">cos</span><span class="p">,</span> <span class="n">diag</span><span class="p">,</span> <span class="n">ones</span><span class="p">,</span> <span class="n">zeros</span>

<span class="c1"># Input Settings</span>
<span class="c1"># Algorithm (T1, T2_individual, T2_synchronised, T2_synchronised_rr)</span>
<span class="n">alg</span> <span class="o">=</span> <span class="s1">&#39;T1&#39;</span>

<span class="c1"># Model type (q - norm quadratic, g/Hz/lbH/E0/Ediag - min eig. quadratic,</span>
<span class="c1"># c - norm cubic, gc - gershgorin cubic)</span>
<span class="n">mod</span> <span class="o">=</span> <span class="s1">&#39;c&#39;</span>

<span class="c1"># Tolerance</span>
<span class="n">tol</span> <span class="o">=</span> <span class="mf">1e-2</span>

<span class="c1"># Tensor diagonal function</span>
<span class="k">def</span> <span class="nf">diagt</span><span class="p">(</span><span class="n">v</span><span class="p">):</span>
    <span class="n">T</span> <span class="o">=</span> <span class="n">zeros</span><span class="p">((</span><span class="n">D</span><span class="p">,</span><span class="n">D</span><span class="p">,</span><span class="n">D</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">D</span><span class="p">):</span>
            <span class="n">T</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">v</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
    <span class="k">return</span> <span class="n">T</span>

<span class="c1"># Set up sum of sines test function</span>
<span class="c1"># Dimension</span>
<span class="n">D</span> <span class="o">=</span> <span class="mi">2</span>
<span class="c1"># Constraints</span>
<span class="n">l</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span><span class="o">*</span><span class="n">ones</span><span class="p">(</span><span class="n">D</span><span class="p">)</span>
<span class="n">u</span> <span class="o">=</span> <span class="mi">1</span><span class="o">*</span><span class="n">ones</span><span class="p">(</span><span class="n">D</span><span class="p">)</span>
<span class="n">A</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span><span class="o">*</span><span class="n">ones</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span><span class="n">D</span><span class="p">))</span>
<span class="n">b</span> <span class="o">=</span> <span class="mi">1</span>
<span class="c1"># Required functions</span>
<span class="n">f</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="nb">sum</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
<span class="n">g</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">cos</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">H</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">diag</span><span class="p">(</span><span class="o">-</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
<span class="n">bndH</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">l</span><span class="p">,</span><span class="n">u</span><span class="p">:</span> <span class="p">(</span><span class="n">diag</span><span class="p">(</span><span class="o">-</span><span class="n">ones</span><span class="p">(</span><span class="n">D</span><span class="p">)),</span> <span class="n">diag</span><span class="p">(</span><span class="n">ones</span><span class="p">(</span><span class="n">D</span><span class="p">)))</span>
<span class="n">bndT</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">l</span><span class="p">,</span><span class="n">u</span><span class="p">:</span> <span class="p">(</span><span class="n">diagt</span><span class="p">(</span><span class="o">-</span><span class="n">ones</span><span class="p">(</span><span class="n">D</span><span class="p">)),</span> <span class="n">diagt</span><span class="p">(</span><span class="n">ones</span><span class="p">(</span><span class="n">D</span><span class="p">)))</span>

<span class="c1"># Name objective function</span>
<span class="n">f</span><span class="o">.</span><span class="n">__name__</span> <span class="o">=</span> <span class="s1">&#39;Sum of Sins&#39;</span>

<span class="c1"># Run oBB</span>
<span class="n">xs</span><span class="p">,</span> <span class="n">fxs</span><span class="p">,</span> <span class="n">tol</span><span class="p">,</span> <span class="n">itr</span> <span class="o">=</span> <span class="n">obb</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">H</span><span class="p">,</span> <span class="n">bndH</span><span class="p">,</span> <span class="n">bndT</span><span class="p">,</span> <span class="n">l</span><span class="p">,</span> <span class="n">u</span><span class="p">,</span> <span class="n">alg</span><span class="p">,</span> <span class="n">mod</span><span class="p">,</span> <span class="n">A</span><span class="o">=</span><span class="n">A</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="n">b</span><span class="p">,</span> <span class="n">tol</span><span class="o">=</span><span class="n">tol</span><span class="p">)</span>
</pre></div>
</div>
</div></blockquote>
<p>This file is included in oBB as sines.py, to run it see <a class="reference internal" href="#running-the-algorithm">Running the Algorithm</a>.</p>
</div>
<div class="section" id="running-the-algorithm">
<h2>Running the Algorithm<a class="headerlink" href="#running-the-algorithm" title="Permalink to this headline">¶</a></h2>
<p>To run the user-created python script file (e.g. sines.py, see <a class="reference internal" href="#example-of-use">Example of Use</a>) we need to execute it using MPI's mpiexec command, specifying the number of processor cores with the -n option. For example, to run oBB on four processor cores we simply execute the following shell command:</p>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre><span></span>$ mpiexec -n <span class="m">4</span> python sines.py
</pre></div>
</div>
</div></blockquote>
<p>Note that if using the MPICH implementation of MPI we first need to start an mpd daemon in the background:</p>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre><span></span>$ mpd <span class="p">&amp;</span>
</pre></div>
</div>
</div></blockquote>
<p>but this is not necessary for other MPI implementations, e.g. OpenMPI.</p>
</div>
<div class="section" id="using-the-rbf-layer">
<h2>Using the RBF Layer<a class="headerlink" href="#using-the-rbf-layer" title="Permalink to this headline">¶</a></h2>
<p>oBB can optionally approximate the objective function <span class="math">\(f\)</span> by a radial basis function (RBF) surrogate and optimize the approximation instead (see <a class="reference internal" href="#fgf2013" id="id8">[FGF2013]</a> for details). The advantage of this approach is that the user merely needs to supply the objective function and a set of points at which it should be evaluated to construct the RBF approximation. The disadvantage is that the optimum found by the algorithm will only be close to the optimum of the objective function if it is sampled at sufficiently many points.</p>
<p>As before, the user is required to write a python script file that defines the functions and parameters necessary to solve the problem and then passes them to the <strong>obb_rbf</strong> function. In addition to the approximation model, algorithm type and objective function arguments described in <a class="reference internal" href="#how-to-use-obb">How to use oBB</a> only an <span class="math">\(n\)</span> by <span class="math">\(m\)</span> numpy array of <span class="math">\(m\)</span> points at which to sample the objective function needs to be passed to the <strong>obb_rbf</strong> function using the <strong>pts</strong> argument.</p>
<p>For example, suppose we wish to solve an RBF approximation to the problem given in the <a class="reference internal" href="#example-of-use">Example of Use</a> section:</p>
<blockquote>
<div><div class="math">
\[\begin{split}&amp;\min_{x \in \mathbb{R}^n} \sum_{i=1}^n \sin(x_i) \\
\text{s.t. } \; &amp;-1 \le x_i \le 1 \; \; \forall i=1,\dotsc,n \\
\text{and }  \; &amp;\sum_{i=1}^n -x_i \le 1\end{split}\]</div>
</div></blockquote>
<p>We can code this up in a python script file, let's call it sines_rbf.py as follows:</p>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># Example RBF Layer code for oBB</span>
<span class="kn">from</span> <span class="nn">obb</span> <span class="kn">import</span> <span class="n">obb_rbf</span>
<span class="kn">from</span> <span class="nn">numpy</span> <span class="kn">import</span> <span class="n">sin</span><span class="p">,</span> <span class="n">ones</span>
<span class="kn">from</span> <span class="nn">numpy.random</span> <span class="kn">import</span> <span class="n">rand</span><span class="p">,</span> <span class="n">seed</span>

<span class="c1"># Input Settings</span>
<span class="c1"># Algorithm (T1, T2_individual, T2_synchronised, T2_synchronised_rr)</span>
<span class="n">alg</span> <span class="o">=</span> <span class="s1">&#39;T1&#39;</span>

<span class="c1"># Model type (q - norm quadratic, g/Hz/lbH/E0/Ediag - min eig. quadratic,</span>
<span class="c1"># c - norm cubic, gc - gershgorin cubic)</span>
<span class="n">mod</span> <span class="o">=</span> <span class="s1">&#39;c&#39;</span>

<span class="c1"># Tolerance</span>
<span class="n">tol</span> <span class="o">=</span> <span class="mf">1e-2</span>

<span class="c1"># Set up sum of sines test function</span>
<span class="c1"># Dimension</span>
<span class="n">D</span> <span class="o">=</span> <span class="mi">2</span>
<span class="c1"># Constraints</span>
<span class="n">l</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span><span class="o">*</span><span class="n">ones</span><span class="p">(</span><span class="n">D</span><span class="p">)</span>
<span class="n">u</span> <span class="o">=</span> <span class="mi">1</span><span class="o">*</span><span class="n">ones</span><span class="p">(</span><span class="n">D</span><span class="p">)</span>
<span class="n">A</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span><span class="o">*</span><span class="n">ones</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span><span class="n">D</span><span class="p">))</span>
<span class="n">b</span> <span class="o">=</span> <span class="mi">1</span>
<span class="c1"># Required functions</span>
<span class="n">f</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="nb">sum</span><span class="p">(</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>

<span class="c1"># Generate 10*D sample points for RBF approximation</span>
<span class="n">seed</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span> <span class="c1"># !!Sample points have to be the same on all processors!!</span>
<span class="n">pts</span> <span class="o">=</span> <span class="n">rand</span><span class="p">(</span><span class="mi">10</span><span class="o">*</span><span class="n">D</span><span class="p">,</span> <span class="n">D</span><span class="p">)</span>

<span class="c1"># Scale points so they lie in [l,u]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">D</span><span class="p">):</span>
    <span class="n">pts</span><span class="p">[:,</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">l</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="p">(</span><span class="n">u</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">-</span><span class="n">l</span><span class="p">[</span><span class="n">i</span><span class="p">])</span><span class="o">*</span><span class="n">pts</span><span class="p">[:,</span><span class="n">i</span><span class="p">]</span>

<span class="c1"># Name objective function</span>
<span class="n">f</span><span class="o">.</span><span class="n">__name__</span> <span class="o">=</span> <span class="s1">&#39;RBF Sum of Sins&#39;</span>

<span class="c1"># Run oBB</span>
<span class="n">xs</span><span class="p">,</span> <span class="n">fxs</span><span class="p">,</span> <span class="n">tol</span><span class="p">,</span> <span class="n">itr</span> <span class="o">=</span> <span class="n">obb_rbf</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">pts</span><span class="p">,</span> <span class="n">l</span><span class="p">,</span> <span class="n">u</span><span class="p">,</span> <span class="n">alg</span><span class="p">,</span> <span class="n">mod</span><span class="p">,</span> <span class="n">A</span><span class="o">=</span><span class="n">A</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="n">b</span><span class="p">,</span> <span class="n">tol</span><span class="o">=</span><span class="n">tol</span><span class="p">)</span>
</pre></div>
</div>
</div></blockquote>
<p>Note the use of <strong>obb_rbf</strong> instead of <strong>obb</strong> and the need for a random number seed so that the sample points are the same on all processors. This file is included in oBB as sines_rbf.py, to run it see <a class="reference internal" href="#running-the-algorithm">Running the Algorithm</a>.</p>
</div>
<div class="section" id="rbf-layer-for-the-coconut-test-set">
<h2>RBF Layer for the COCONUT Test Set<a class="headerlink" href="#rbf-layer-for-the-coconut-test-set" title="Permalink to this headline">¶</a></h2>
<p>oBB comes with a set of pre-computed RBF approximations to selected functions from the <a class="reference external" href="http://www.mat.univie.ac.at/~neum/glopt/coconut/Benchmark/Benchmark.html">COCONUT test set</a> that were used to produce the numerical results in the paper <a class="reference internal" href="#cfg2013" id="id9">[CFG2013]</a>. In order to optimize these approximations using oBB, the user is required to write a python script file that defines the desired function and tolerance and then passes them to the <strong>obb_rbf_coconut</strong> function (see <a class="reference internal" href="#cfg2013" id="id10">[CFG2013]</a> for a list of all 31 functions available). For example, to optimize an RBF approximation to the <strong>'hs041'</strong> function the user could write the following python script file, let's call it coconut.py:</p>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># Example COCONUT RBF code for oBB</span>
<span class="kn">from</span> <span class="nn">obb</span> <span class="kn">import</span> <span class="n">obb_rbf_coconut</span>

<span class="c1"># Input Settings</span>
<span class="c1"># Algorithm (T1, T2_individual, T2_synchronised, T2_synchronised_rr)</span>
<span class="n">alg</span> <span class="o">=</span> <span class="s1">&#39;T1&#39;</span>

<span class="c1"># Model type (q - norm quadratic, g/Hz/lbH/E0/Ediag - min eig. quadratic,</span>
<span class="c1"># c - norm cubic, gc - gershgorin cubic)</span>
<span class="n">mod</span> <span class="o">=</span> <span class="s1">&#39;c&#39;</span>

<span class="c1"># Tolerance (can also be &#39;12hr&#39;)</span>
<span class="n">tol</span> <span class="o">=</span> <span class="mf">1e-2</span>

<span class="c1"># Choose RBF approximation from COCONUT test</span>
<span class="n">f</span> <span class="o">=</span> <span class="s1">&#39;hs041&#39;</span>

<span class="c1"># Run oBB</span>
<span class="n">xs</span><span class="p">,</span> <span class="n">fxs</span><span class="p">,</span> <span class="n">tol</span><span class="p">,</span> <span class="n">itr</span> <span class="o">=</span> <span class="n">obb_rbf_coconut</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">alg</span><span class="p">,</span> <span class="n">mod</span><span class="p">,</span> <span class="n">tol</span><span class="o">=</span><span class="n">tol</span><span class="p">)</span>
</pre></div>
</div>
</div></blockquote>
<p>Note the use of <strong>obb_rbf_coconut</strong> as the calling function and the optional <strong>'12hr'</strong> tolerance setting which runs the algorithm to the absolute tolerance obtained by a serial code in twelve hours (see <a class="reference internal" href="#cfg2013" id="id11">[CFG2013]</a> for details). This file is included in oBB as coconut.py, to run it see <a class="reference internal" href="#running-the-algorithm">Running the Algorithm</a>.</p>
</div>
<div class="section" id="acknowledgements">
<h2>Acknowledgements<a class="headerlink" href="#acknowledgements" title="Permalink to this headline">¶</a></h2>
<p>This work was supported by EPSRC grants <a class="reference external" href="http://gow.epsrc.ac.uk/NGBOViewGrant.aspx?GrantRef=EP/I028854/1">EP/I028854/1</a> (PI: <a class="reference external" href="http://www.maths.ox.ac.uk/people/profiles/coralia.cartis">Dr Coralia Cartis</a>) and NAIS <a class="reference external" href="http://gow.epsrc.ac.uk/NGBOViewGrant.aspx?GrantRef=EP/G036136/1">EP/G036136/1</a>.
We are also grateful to <a class="reference external" href="http://www.numerical.rl.ac.uk/people/nimg/">Prof Nick Gould</a> for his help and advice during development, Mehdi Towhidi for providing us with his <a class="reference external" href="http://github.com/mpy/PyQuadProg">PyQuadProg code</a> and Alberto Guida for his range reduction strategy enhancement.</p>
</div>
<div class="section" id="references">
<h2>References<a class="headerlink" href="#references" title="Permalink to this headline">¶</a></h2>
<table class="docutils citation" frame="void" id="cfg2013" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[CFG2013]</td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id4">2</a>, <a class="fn-backref" href="#id5">3</a>, <a class="fn-backref" href="#id7">4</a>, <a class="fn-backref" href="#id9">5</a>, <a class="fn-backref" href="#id10">6</a>, <a class="fn-backref" href="#id11">7</a>)</em> Cartis, C., Fowkes, J. M. and Gould, N. I. M. (2013) 'Branching and Bounding Improvements for Global Optimization Algorithms with Lipschitz Continuity Properties', <em>ERGO Technical Report</em>, no. 13-010, pp. 1-33. <a class="reference external" href="http://www.maths.ed.ac.uk/ERGO/pubs/ERGO-13-010.html">http://www.maths.ed.ac.uk/ERGO/pubs/ERGO-13-010.html</a></td></tr>
</tbody>
</table>
<table class="docutils citation" frame="void" id="fgf2013" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[FGF2013]</td><td><em>(<a class="fn-backref" href="#id2">1</a>, <a class="fn-backref" href="#id8">2</a>)</em> Fowkes, J. M. , Gould,  N. I. M. and Farmer, C. L. (2013) 'A Branch and Bound Algorithm for the Global Optimization of Hessian Lipschitz Continuous Functions', <em>Journal of Global Optimization</em>, vol. 56, no. 4, pp. 1791-1815. <a class="reference external" href="http://dx.doi.org/10.1007/s10898-012-9937-9">http://dx.doi.org/10.1007/s10898-012-9937-9</a></td></tr>
</tbody>
</table>
<table class="docutils citation" frame="void" id="g2015" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[G2015]</td><td><em>(<a class="fn-backref" href="#id3">1</a>, <a class="fn-backref" href="#id6">2</a>)</em> Guida, A. (2015) 'A Branch and Bound Algorithm for the Global Optimization and its Improvements', Master's Thesis, Faculty of Engineering, University of Florence, pp. 1-88. <a class="reference external" href="http://people.maths.ox.ac.uk/cartis/papers/Thesys_Alberto_Guida.pdf">http://people.maths.ox.ac.uk/cartis/papers/Thesys_Alberto_Guida.pdf</a></td></tr>
</tbody>
</table>
</div>
</div>


           </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
      
        <a href="install.html" class="btn btn-neutral" title="Installing oBB" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2016, J. M. Fowkes.
      Last updated on 18 Jul, 2016.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'./',
            VERSION:'0.8b',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true
        };
    </script>
      <script type="text/javascript" src="_static/jquery.js"></script>
      <script type="text/javascript" src="_static/underscore.js"></script>
      <script type="text/javascript" src="_static/doctools.js"></script>
      <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

  

  
  
    <script type="text/javascript" src="_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>